package pct.post;

import java.util.LinkedList;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import pct.database.PcServiceImpl;
import pct.entity.Message;
import pct.manage.StatusManager;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

public class HandleBadInfo extends ActionSupport implements SessionAware,
		Preparable {

	private Map<String, Object> session;
	private PcServiceImpl pcService = new PcServiceImpl();
	private String action;
	private int postID;
	private int messageID;
	private LinkedList<Message> reportMsg = new LinkedList<Message>();

	public String execute() {
		if (action.equals("remove")) {
			pcService.removePost(postID);
			pcService.updateReportMessage(postID, 2);
		}
		else if(action.equals("ignore"))
		{
			pcService.updateReportMessage(postID, 1);
		}
		reportMsg = pcService.getReportMessage();
		session.put("reportMsg", reportMsg);
		return SUCCESS;
	}

	public int getMessageID() {
		return messageID;
	}

	public void setMessageID(int messageID) {
		this.messageID = messageID;
	}

	public int getPostID() {
		return postID;
	}

	public void setPostID(int postID) {
		this.postID = postID;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;
		// TODO Auto-generated method stub

	}

	@Override
	public void prepare() throws Exception {
		pcService.connectDB();

	}
}
